package com.zwj.batch.config.springBatch;

import com.zwj.batch.config.springBatch.incrementer.DailyTimestampParamIncrementer;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.item.validator.BeanValidatingItemProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 张文接
 * @version 1.0
 * @createTime 2023-06-25 10:32:00
 */
@Configuration
public class BatchConfig {

    /**
     * 开启对实体类的校验
     *
     * @return 结果
     */
    @Bean
    public BeanValidatingItemProcessor<Object> beanValidatingItemProcessor() {
        BeanValidatingItemProcessor<Object> validatingItemProcessor = new BeanValidatingItemProcessor<>();
        //不满足条件，责丢弃数据
        validatingItemProcessor.setFilter(true);
        return validatingItemProcessor;
    }

    @Bean
    public JobParametersBuilder jobParametersBuilder() {
        return new JobParametersBuilder();
    }

    @Bean
    public DailyTimestampParamIncrementer dailyTimestampParamIncrementer() {
        return new DailyTimestampParamIncrementer();
    }
}
